<div class="modal" ng-controller="FlowableCaseReferencePopupCtrl">
  <div class="modal-dialog modal-wide">
    <div class="modal-content">
      <div class="modal-header">
        <button aria-hidden="true" class="close" data-dismiss="modal" ng-click="close()" type="button">&times;</button>
        <h2>
          {{'PROPERTY.CASEREFERENCE.TITLE' | translate}}
          <span ng-show="selectedCase != null"> - {{selectedCase.name}}</span>
          <span ng-show="selectedCase == null"> - {{'PROPERTY.CASEREFERENCE.EMPTY' | translate}}</span>

        </h2>
      </div>
      <div class="modal-body-with-overflow">
        <div class="detail-group clearfix">
          <div class="col-xs-12">
            <div class="alert alert-error" ng-show="!state.loadingCases && state.caseError" translate>
              PROPERTY.CASEREFERENCE.ERROR.FORM
            </div>
          </div>
        </div>
        <div class="detail-group clearfix">
          <div class="col-xs-12 editor-item-picker">
            <div class="col-xs-4 editor-item-picker-component" ng-class="{'selected' : caseModel.id == selectedCase.id}"
                 ng-click="selectCase(caseModel, $event)" ng-if="!state.loadingCases && !state.caseError"
                 ng-repeat="caseModel in caseModels">
              <div class="controls">
                <input ng-checked="caseModel.id == selectedCase.id" ng-click="selectCase(caseModel, $event)"
                       type="checkbox"
                       value="option1"/>
              </div>
              <h4>{{caseModel.name}}</h4>
              <img ng-src="{{getModelThumbnailUrl(caseModel.id)}}"/>
            </div>
            <div ng-show="state.loadingCases">
              <p class="loading" translate>PROPERTY.CASEREFERENCE.CASE.LOADING</p>
            </div>
            <div ng-show="!state.loadingCases && caseModels.length == 0">
              <p translate>PROPERTY.CASEREFERENCE.CASE.EMPTY</p>
            </div>
          </div>
        </div>
      </div>
      <div class="modal-footer">
        <button class="btn btn-primary" ng-click="close()" translate>GENERAL.ACTION.CANCEL</button>
        <button class="btn btn-primary" ng-click="open()" ng-disabled="!selectedCase || state.caseError" translate>
          GENERAL.ACTION.OPEN
        </button>
        <button class="btn btn-primary" ng-click="save()" ng-disabled="state.caseError" translate>GENERAL.ACTION.SAVE
        </button>
      </div>
    </div>
  </div>
</div>
